package com.fcg.redis.rediscommon.consts;

import lombok.Getter;

import java.util.concurrent.TimeUnit;

/**
 * @author FCG
 */

@Getter
public enum CacheTimeOut {
    /**
     * 有效时间最长: 6 小时
     */
    MAX(6, TimeUnit.HOURS),
    /**
     * 有效时间最段: 10 秒钟
     */
    MIN(10, TimeUnit.SECONDS),
    /**
     * 默认的cookie(token) 有效时间
     */
    COOKIE(30, TimeUnit.MINUTES);

    private long timeOut;
    private TimeUnit unit;

    CacheTimeOut(long timeOut, TimeUnit unit) {
        this.timeOut = timeOut;
        this.unit = unit;
    }

    public long toSeconds() {
        return this.getUnit().toSeconds(this.getTimeOut());
    }
}
